package cn.whdream.pro;

public class App {
	
	public static void main(String[] args) {
		Movie m = new Movie();
		Player player = new Player(m);
		Watcher watcher = new Watcher(m);
		Thread th = new Thread(player);
		th.start();
		Thread th1 = new Thread(watcher);
		th1.start();
	}
	private static class Player implements Runnable{
		Movie m;
		
		public Player(Movie m) {
			super();
			this.m = m;
		}

		@Override
		public void run() {
			for (int i = 0; i < 20; i++) {
				if(i%2 == 0) {
					m.play("左青龙");
				}else {
					m.play("右白虎");
				}
			}
		}
		
	}
	
	private static class Watcher implements Runnable {
		Movie m;
		
		public Watcher(Movie m) {
			super();
			this.m = m;
		}

		@Override
		public void run() {
			for (int i = 0; i < 20; i++) {
				m.watch();
			}
			
		}
		
	}
}

